package com.apps.gomdiem.activity;
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;

import com.apps.gomdiem.R;
import com.apps.gomdiem.fragment.HomeTabFragment;
import com.apps.gomdiem.fragment.MenuTabFragment;
import com.apps.gomdiem.fragment.ProfileTabFragment;
import com.apps.gomdiem.fragment.SearchTabFragment;
import com.google.android.gms.internal.el;


/**
 * Cái TabActivity này bị depcrecation rồi, nó có gợi ý là sử dụng TabFragment đó
 * Trung nghiên cứu fragment đi, nếu đc thì sửa dụng cái tab fragment cho trang này
 * @author Kypi221
 *
 */

public class MainActivity extends FragmentActivity{
	public static FragmentTabHost mTabHost;
	
	private int currentBannerIndex = 0;
	private String[] listBanner = new String[]{
		"Đây là quảng cáo 1",
		"Đây là quảng cáo 2",
		"Đây là quảng cáo 3",
		"Đây là quảng cáo 4",
		"Đây là quảng cáo 5",
	};
	
	private AnimationListener animationlistener = new AnimationListener() {
		
		@Override
		public void onAnimationStart(Animation arg0) {
			// TODO Auto-generated method stub
			
		}
		
		@Override
		public void onAnimationRepeat(Animation arg0) {
			currentBannerIndex++;
			if(currentBannerIndex == listBanner.length){
				currentBannerIndex = 0;
			}
			txtBanner.setText(listBanner[currentBannerIndex]);
		}
		
		@Override
		public void onAnimationEnd(Animation arg0) {
			// TODO Auto-generated method stub
			
		}
	};
	


	private TextView txtBanner;    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        setContentView(R.layout.main_activity);
        mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
        mTabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);
        mTabHost.addTab(mTabHost.newTabSpec("Home").setIndicator("Home"),
        		HomeTabFragment.class, null);
        mTabHost.addTab(mTabHost.newTabSpec("Search").setIndicator("Search"),
        		SearchTabFragment.class, null);
        mTabHost.addTab(mTabHost.newTabSpec("Menu").setIndicator("Menu"),
        		MenuTabFragment.class, null);
        mTabHost.addTab(mTabHost.newTabSpec("Profile").setIndicator("Profile"),
        		ProfileTabFragment.class, null);
        
        txtBanner = (TextView) findViewById(R.id.txtBanner);
        
        TranslateAnimation animation = (TranslateAnimation) AnimationUtils.loadAnimation(this,R.anim.banner);
        animation.setAnimationListener(animationlistener );
        txtBanner.startAnimation(animation);

      
    }
    
}
